-
Notifications
You must be signed in to change notification settings - Fork 123
Add AsHandleValue trait to safely convert Heap<Value> to HandleValue #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
|
So if I understand correctly, as_handle_value Is only safe If it's stored inside a structure that is traced by SpiderMonkey (e.g. inside a RootedGuard, JS::Rooted or custom traceable struct) I can rename it to context: |
I'm not a fan of this solution because it doesn't actually force the caller to use it in a safe way; it just hides an unsafe conversion. |
I think if we annotate Heap with the crown::unrooted_must_root so that we can have unrooted values be compiler errors I would be willing to reevaluate this. |
I would also prefer creating the rust::Handle values from the Heap values directly so the lifetime comes from the self value. Handle::from_raw is really unsafe because the lifetime has no relationship with the original source. |
Wouldn't that be to strict in some cases? |
I'm having trouble coming up with those cases. |
In this case we should put the trait in servo, as we need crown to ensure it's safety. |
I will do that in Servo. |
sounds good. |
Needed for servo/servo#37258